import os.path
import time
import unittest
from HTMLTestRunner import HTMLTestRunner


# loaer
loader = unittest.defaultTestLoader.discover('test_cases', 'test*')



# TODO runner 使用HTMLTestRunner执行器
# 准备要写入的文件
# 年月份时分秒 login.html
report = os.path.abspath('report')
filename = time.strftime('%Y%m%d%H%M%S') + '-demo.html'
file_path = os.path.join(report, filename)

# 写入文件  执行测试用例  生成测试报告
with open(file_path, 'wb') as f:
    runner = HTMLTestRunner(
        title='测试报告标题',
        stream =f,
        verbosity=2
    )
    runner.run(loader)